jQuery(document).ready(function() {
	jQuery('#slideshow').cycle({
		fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		pager: '#smallnav', 
		pause:   1, 
		speed: 1800,
		timeout:  3500 
	});
	jQuery('#zipcode').keypress(function (e){
		if(e.which == 13) {
			jQuery.post(BASE_URL + 'zipcode/find', {zipcode: jQuery('#zipcode').val()}, function(data){
				if(data.result){
					window.location.href = data.domain;
				}else{
					alert(data.message);
				}
			}, 'json');
			return false;
	    }
		if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57)){
			return false;
		}
	});
	
	jQuery('#search-button').click(function(){
		jQuery.post(BASE_URL + 'zipcode/find', {zipcode: jQuery('#zipcode').val()}, function(data){
			if(data.result){
				window.location.href = data.domain;
			}else{
				alert(data.message);
			}
		}, 'json');
		return false;
	});

});

function onfocusText(text, obj){
	if(jQuery(obj).val() == text){
		jQuery(obj).val('');
	}
}

function onblurText(text, obj){
	if(jQuery(obj).val() == ''){
		jQuery(obj).val(text);
	}
}